<%@page import="study.itwill.team5.admin.AdminItem"%>
<%@page import="study.itwill.jsp.WebHandler"%>
<%@page import="study.itwill.team5.house.HouseItem"%>
<%@page import="study.itwill.team5.house.House"%>
<%@page import="study.itwill.team5.member.MemberItem"%>
<%@page import="study.itwill.team5.member.Member"%>
<%@page import="java.util.ArrayList"%>
<%@page import="study.itwill.common.DBHandler"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ include file="../session.jsp"%>
<%@ include file="../dbcon.jsp"%>
<%
	// 회원에 대한 ArrayList 받아오기
	Member member = new Member();
	ArrayList<MemberItem> member_list = member.listMember(0);
	
	// 민박에 대한 ArrayList 받아오기
	House house = new House();
	ArrayList<HouseItem> house_list = house.listHouse(0);
%>
<!DOCTYPE html>
<html lang="ko">
<head>
<%@ include file="../head.jsp"%>
</head>
<body>
	<%@ include file="../menu.jsp"%>
	<div class="container">
		<div class="page-header">
			<h1>
				나의찜 추가 - <small>새로운 나의찜을 추가하세요.</small>
			</h1>
		</div>

		<form id="frmWishlistAdd" class="form-horizontal" role="form"
			method="post" action="addWishlistOk.jsp">
			<fieldset>

				<!-- 입력양식 -->
				<div class="form-group">
					<label for="member_seq" class="col-md-2 control-label">회원</label>
					<div class="col-md-10">
						<select id="member_seq" name="member_seq" class="form-control"
							autofocus>
							<option>----- 선택하세요 -----</option>
							<%
							if (member_list != null) {
								for (int i=0; i<member_list.size(); i++) {
									MemberItem item = member_list.get(i);
						%>
							<option value="<%=item.getSeq()%>"><%=item.getUser_name()%>
								/
								<%=item.getEmail1()%>@<%=item.getEmail2()%></option>
							<%			
								}
							}
						%>
						</select>
					</div>
				</div>

				<div class="form-group">
					<label for="house_seq" class="col-md-2 control-label">민박</label>
					<div class="col-md-10">
						<select id="house_seq" name="house_seq" class="form-control">
							<option>----- 선택하세요 -----</option>
							<%
							if (house_list != null) {
								for (int i=0; i<house_list.size(); i++) {
									HouseItem item = house_list.get(i);
						%>
							<option value="<%=item.getSeq()%>"><%=item.getName()%></option>
							<%			
								}
							}
						%>
						</select>
					</div>
				</div>

				<div class="form-group">
					<div class="col-md-offset-2 col-md-10">
						<div class="row">
							<div class="col-md-6">
								<button type="submit" class="btn btn-primary btn-block">저장하기</button>
							</div>
							<div class="col-md-6">
								<button type="reset" class="btn btn-warning btn-block">다시작성</button>
							</div>
						</div>

					</div>
				</div>

			</fieldset>
		</form>
	</div>
	<% db.disconnect(); %>
	<!-- Javascript -->
	<script src="/Team-Project/assets/js/jquery.js"></script>
	<script src="/Team-Project/assets/js/bootstrap.min.js"></script>
	<!-- 형식검사 클래스 참조 -->
	<script src="/Team-Project/assets/js/string.js"></script>
	<!-- 구현부분 -->
	<script type="text/javascript">
		// jquery main()
		$(function() {
			$("#frmWishlistAdd").submit(function() {
				
				// 회원 선택여부 검사
				if ($("select[name='member_seq'] > option:selected").index() < 1) {
					alert("회원을 선택하세요.");
					$("select[name='member_seq']").focus();
					return false;
				}
				
				// 민박 선택여부 검사
				if ($("select[name='house_seq'] > option:selected").index() < 1) {
					alert("민박을 선택하세요.");
					$("select[name='house_seq']").focus();
					return false;
				}
				
			});
		});
	</script>

</body>
</html>